package com.qqbot.impl.exception;

import com.qqbot.impl.exception.code.BaseResponseCode;
import com.qqbot.impl.exception.code.ResponseCodeInterface;

/**
 * 异常
 *
 * @author changwenpeng
 * @date 2022年5月28日
 */
public class BException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    /**
     * 异常编号
     */
    private final int messageCode;

    /**
     * 对messageCode 异常信息进行补充说明
     */
    private final String detailMessage;

    public BException(int messageCode, String message) {
        super(message);
        this.messageCode = messageCode;
        this.detailMessage = message;
    }

    public BException(String message) {
        super(message);
        this.messageCode = BaseResponseCode.OPERATION_ERRO.getCode();
        this.detailMessage = message;
    }

    /**
     * 构造函数
     *
     * @param code 异常码
     */
    public BException(ResponseCodeInterface code) {
        this(code.getCode(), code.getMsg());
    }

    public int getMessageCode() {
        return messageCode;
    }

    public String getDetailMessage() {
        return detailMessage;
    }

}
